package com.Dao;

import com.utils.QueryRunnerUtils2;

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.*;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

public class FatherDao {
    public QueryRunner queryRunner=new QueryRunnerUtils2().getQueryRunner();



    public List<Map<String ,Object>> queryListForMap(String sql,Object...params) throws SQLException {
        return  queryRunner.query(sql,new MapListHandler(),params);
    }

    public  Map<String ,Object> queryForMap(String sql,Object...params) throws SQLException {
        return queryRunner.query(sql, new MapHandler(),params);
    }

    public <T> List<T> queryForListObject(String sql,Class<T> clas,Object...params) throws SQLException {
        return  queryRunner.query(sql,new BeanListHandler<T>(clas),params);
    }

    public  <T> T queryForObject(String sql,Class<T> clas,Object...params) throws SQLException {
        return  queryRunner.query(sql,new BeanHandler<T>(clas),params);
    }

    public List<Object[]> getValuesForObject(String sql,Object...params) throws SQLException {
       return queryRunner.query(sql, new ArrayListHandler(),params);
    }

    public  Object[] getValueForObject(String sql,Object...params) throws SQLException {
        return queryRunner.query(sql,new ArrayHandler(),params);
    }

    public Long getTotalCount(String sql,Object...params) throws SQLException {
        return  queryRunner.query(sql,new ScalarHandler<Long>(),params);
    }

}
